package networking.config.parser;

import java.net.DatagramSocket;
import java.net.ServerSocket;
import java.net.Socket;

/*
 * A node can be both a server and a client.
 */
public class Node {

	// General
	private Integer nodeID;
	private String ip;
	private Integer port;

	// TCP
	private Socket tcpClientSocket;
	private ServerSocket tcpServerSocket;
	private Socket tcpServerSocketPerClient;

	// UDP
	private DatagramSocket udpServerSocket;
	private DatagramSocket udpClientSocket;

	public Node(Integer nodeID, String ip, Integer port) {

		this.nodeID = nodeID;
		this.ip = ip;
		this.port = port;

	}

	public Integer getNodeID() {
		return nodeID;
	}

	public void setNodeID(Integer nodeID) {
		this.nodeID = nodeID;
	}

	public Integer getPort() {
		return port;
	}

	public void setPort(Integer port) {
		this.port = port;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public Socket getClientSocket() {
		return tcpClientSocket;
	}

	public void setClientSocket(Socket clientSocket) {
		this.tcpClientSocket = clientSocket;
	}

	public ServerSocket getServerSocket() {
		return tcpServerSocket;
	}

	public void setServerSocket(ServerSocket serverSocket) {
		this.tcpServerSocket = serverSocket;
	}

	public void setServerSocketPerClient(Socket serverSocketPerClient) {
		this.tcpServerSocketPerClient = serverSocketPerClient;

	}

	public Socket getServerSocketPerClient() {
		return this.tcpServerSocketPerClient;

	}

	public DatagramSocket getUdpServerSocket() {
		return udpServerSocket;
	}

	public void setUdpServerSocket(DatagramSocket udpServerSocket) {
		this.udpServerSocket = udpServerSocket;
	}

	public DatagramSocket getUdpClientSocket() {
		return udpClientSocket;
	}

	public void setUdpClientSocket(DatagramSocket udpClientSocket) {
		this.udpClientSocket = udpClientSocket;
	}

	@Override
	public String toString() {
		System.out.println("Node ID: " + this.nodeID.toString() + " IP: " + this.ip.toString() + " port: " + this.port.toString());
		return super.toString();
	}

}
